package com.leo.oplayer;

import android.app.TabActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.CallLog;
import android.util.Log;
import android.view.Window;
import android.widget.TabHost;

import com.leo.oplayer.filter.SmsObserver;
import com.leo.oplayer.filter.TeleObserver;
import com.leo.oplayer.util.Constancts;
import com.leo.oplayer.view.ConfigView;
import com.leo.oplayer.view.RadarView;
import com.leo.oplayer.view.RankView;


public class MainActivity extends TabActivity {
	private static final String TAG = "MainActivity";
	
//	private DBService service;
	
//	private ContactService contactService;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
//        service = new DBService(this);
//        contactService = new ContactService(service);        
		
		final TabHost host = getTabHost();
		
		host.addTab(host.newTabSpec("radar")
					.setIndicator("RADAR-VIEW", getResources().getDrawable(R.drawable.tab_radar))
					.setContent(new Intent(this, RadarView.class)));
		
		host.addTab(host.newTabSpec("rank")
				.setIndicator("RANK-VIEW", getResources().getDrawable(R.drawable.tab_rank))
				.setContent(new Intent(this, RankView.class)));
		
		host.addTab(host.newTabSpec("config")
				.setIndicator("CONFIG", getResources().getDrawable(R.drawable.tab_config))
				.setContent(new Intent(this, ConfigView.class)));
		
		//设置当前显示的tab
//		host.setCurrentTab(2);
		    
             
		
        //bingo!!!!!!!
        //test Observer
        getContentResolver().registerContentObserver(Uri.parse(Constancts.URI_SMS),
				true, new SmsObserver(this, new Handler()));
        
        getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI,
				true, new TeleObserver(this, new Handler()));
        
        Log.i(TAG, "MainActivity create!");    
      
////       测试启动定时检查
//        Calendar c = Calendar.getInstance();
//		
//		 /* 指定闹钟设置时间到时要运行CallAlarm.class */
//       Intent i = new Intent(this,CheckAlarm.class);
//       
//       PendingIntent sender = PendingIntent.getBroadcast(this,1, i, 0);
//       /* setRepeating()可让闹钟重复运行 */
//       AlarmManager am;
//       int times= 60*1000;
//       am = (AlarmManager)getSystemService(ALARM_SERVICE);
//       am.setRepeating(AlarmManager.RTC_WAKEUP,
//                 c.getTimeInMillis(),times,sender);
//       
       Log.i(TAG, "create finish!");    
        
    }
    
}